﻿#ifndef HIDINTERFACEIMPL_H
#define HIDINTERFACEIMPL_H

#include "hid_interface.h"
#include "hidapi/hidapi.h"
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>

using namespace std;

/**
 * 实现 hid_interface 接口，用于和驱动通讯
 * @brief The HIDInterfaceImpl class
 */
class HIDInterfaceImpl : public hid_interface {

public:
  HIDInterfaceImpl();
  ~HIDInterfaceImpl();

private:
  hid_device *hidDevice = nullptr;

public:
  /* 打开 HID 设备 */
  int open(unsigned short vendor_id, unsigned product_id);

  /* 读取数据 */
  int read(char *data, int length);

  /* 写数据 */
  int write(char *data, int length);

  /* 获取打开状态 */
  int isOpen();

  /* 关闭 HID 设备*/
  int close();
};
#endif // HIDINTERFACEIMPL_H
